package com.zys.el.time.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zys.el.time.service.redis.ScrollDetail;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

/**
 * 评论
 * @TableName comment
 */
@TableName(value ="comment")
@Data
@NoArgsConstructor
public class Comment implements Serializable, ScrollDetail {
    /**
     * 评论id
     */
    @TableId
    protected Long commentId;

    /**
     * 根评论id
     */
    protected Long rootCommentId;

    /**
     * 帖子id
     */
    protected Long thinkingId;

    /**
     * 用户id
     */
    protected Long userId;

    /**
     * 评论
     */
    protected String text;

    /**
     * 被评论者id
     */
    protected Long replieeId;

    /**
     * 状态(1：正常，2：审核中，3：未过审)
     */
    protected Integer status;

    /**
     * 创建时间
     */
    protected LocalDateTime createTime;

    /**
     * 更新时间
     */
    protected LocalDateTime updateTime;

    /**
     * 是否删除(0-未删, 1-已删)
     */
    @TableLogic
    @TableField(select = false)
    protected Integer isDeleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public long getScore() {
        return this.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli();
    }

    @Override
    public long getId() {
        return this.commentId;
    }
}